/*
* 倒计时
*
*/
let timer = null;
export const countDown = (count, cb) => {
    let countNum = count;
    if(!timer) {
        timer = setInterval(()=> {
            if(countNum > 0 && countNum <= count) {
                countNum--;
                cb(countNum);
            }else{
                clearInterval(timer);
                timer = null;
                cb(null);
            }
        }, 1000);
    }
};
export const clearCountDown = () => {
    clearInterval(timer);
};

/**
 * 防抖
 * 
*/
let throttleTimer = null;
export const throttle = (time = 1000) => {
    if(!throttleTimer) {
        throttleTimer = setTimeout(()=> {
            throttleTimer = null;
        }, time);
        return throttleTimer;
    }
};


